package ac.svn.accesscontrol.context;

import java.util.HashMap;
import java.util.UUID;

public class Context extends HashMap<String, Object>
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String contextName = null;
	private String contextId   = null;	
	private boolean modified = false;

	
	public Context(String contextName)
	{
		super();
		this.contextName = contextName;
		this.contextId = String.format("Context[%s(%s)]",UUID.randomUUID().toString(),contextName);  
	}

	public Context clone()
	{
		Context context = new Context(String.format("Clone[%s]",contextName));
		for(String key : super.keySet())
		{
			Object value = get(key);
			context.put(key, value);
		}
		
		return context;
	}
	
	public String getContextName() {
		return contextName;
	}

	public void setContextName(String contextName) {
		this.contextName = contextName;
	}

	public String getContextId() {
		return contextId;
	}

	/* (non-Javadoc)
	 * @see java.util.HashMap#put(java.lang.Object, java.lang.Object)
	 */
	@Override
	public Object put(String key, Object value) {
		modified = true;
		return super.put(key, value);
	}

	/**
	 * @return the modified
	 */
	public boolean isModified() {
		return modified;
	}

	/**
	 * @param modified the modified to set
	 */
	public void setModified(boolean modified) {
		this.modified = modified;
	}
	
	
	
	
}
